<?php
class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        
        $formLogin = new Application_Form_Login();
        $this->view->formLogin = $formLogin;
        $model =new Application_Model_Noticias();
        $this-> view->noticias=$model->getAll();
        $modelTesis =new Application_Model_Tesis();
        $this-> view->tesis=$modelTesis->getAll();
        $modelPersona =new Application_Model_Personas();
        $this-> view->persona=$modelPersona->getAll();
        if(Zend_Auth::getInstance()->hasIdentity()){
            $skin=Zend_Auth::getInstance()->getIdentity()->skin;
            $this->_helper->Cambiarskin($skin);
        }
    }
    public function indexAction()
    {
     
       $modelHome=new Application_Model_Homes();
       $titulo=$modelHome->getRow(1)->titulo_home;
       $cuerpo=$modelHome->getRow(1)->cuerpo_home;
       $this->view->titulo=$titulo;
       $this->view->cuerpo=$cuerpo;
        
    }
    public function editarindexAction(){
        
        $formHome=new Application_Form_Home();
        $modelHome=new Application_Model_Homes();
        $modelHome2=new Application_Model_Homes();
        if($this->getRequest()->isPost()){
            if($formHome->isValid($this->_getAllParams())){
                $modelHome->save($formHome->getValues(),1);
            }
        }else{
            $row=$modelHome2->getRow(1);
            if($row){
                $formHome->populate($row->toArray());   
            }
        }
       $this->view->formHome=$formHome;
    }
}

